import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:rxdart/rxdart.dart';


class BaseProvide with ChangeNotifier{

  CompositeSubscription _compositeSubscription =CompositeSubscription();
  CompositeSubscription get compositeSubscription => _compositeSubscription; //

  void addSubscription(StreamSubscription subscription){
    _compositeSubscription.add(subscription);
  }
  //
  void removeSubscription(StreamSubscription subscription){
     _compositeSubscription.remove(subscription);
  }

  @override
  void dispose() {
    super.dispose();
    _compositeSubscription.dispose();
  }


}
//解决 如果是list 的情况下  改变list的单一对象  ChangeNotifier不触发刷新问题
// 注意： 需要把返回的list 重新赋值给原列表   才能生效
//  次方案为 临时替代方案
List<T> notifyList<T>(ChangeNotifier changeNotifier,List<T> list){
  List<T> copyList= [...list];
  list.clear();
  list=copyList;
  changeNotifier.notifyListeners();
  return copyList;
}